package com.qf.game;

import java.util.Random;

/**
 * 匕首类
 */
public class Dagger extends Weapon{
    private double baojixishu;

    public double getBaojixishu() {
        return baojixishu;
    }

    public void setBaojixishu(double baojixishu) {
        this.baojixishu = baojixishu;
    }

    @Override
    public int dealDamage() {
        //获取武器的基础伤害
        int basicDamage = super.dealDamage();
        //计算是否暴击了
        boolean flag = baoji();
        if (flag){
            System.out.println("打出了暴击！！！");
            //暴击后等于基础伤害+暴击系数
            double v = basicDamage*(1+baojixishu);
            return (int)v;
        }else{
            //不暴击就是基础伤害
            return (basicDamage - 30);
        }
    }
    public boolean baoji(){
        //预期暴击率
        Random random = new Random();
        //0-99的随机数
        int num = random.nextInt(100);
        if(num<75){
            //暴击了
            return true;
        }else {
            return false;
        }
    }
}
